package com.example.apple.hxbtc.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.example.apple.hxbtc.MainActivity;
import com.example.apple.hxbtc.R;

/**
 * Created by hpz on 17/2/25.
 */

public class WelcomeActivity extends Activity {

    private Handler mHandler;

    private static final int SEND_MSG_ID = 0x0001;
    private static final int EXIT_MSG_ID = 0x0002;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);

        initData();
        /*Handler handler = new Handler();
        Runnable updateThread = new Runnable() {
            public void run() {
                Intent intent = new Intent();
                intent.setClass(WelcomeActivity.this, MainActivity.class);
                startActivity(intent);
                finish();
            }

        };
        handler.postDelayed(updateThread, 2000);
    }*/
    }

    private void initData() {
        mHandler = new Handler(){

            @Override
            public void handleMessage(Message msg) {
                switch (msg.what) {
                    case SEND_MSG_ID:
                        goMainActivity();
                        break;
                    case EXIT_MSG_ID:
                        finish();
                        break;
                    default:
                        break;
                }
            }

        };
        mHandler.sendEmptyMessageDelayed(SEND_MSG_ID, 2000);
    }

    private void goMainActivity() {
        Intent intent = new Intent();
        intent.setClass(this, MainActivity.class);
        startActivity(intent);
        finish();
    }
}